home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 3.iso / dist / fw_bind.idb / usr / freeware / include / bind / netdb.h.z / netdb.h
Encoding:
C/C++ Source or Header  |  2001-04-12  |  15.3 KB  |  475 lines

  1. /*
  2.  * ++Copyright++ 1980, 1983, 1988, 1993
  3.  * -
  4.  * Copyright (c) 1980, 1983, 1988, 1993
  5.  *    The Regents of the University of California.  All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 1. Redistributions of source code must retain the above copyright
  11.  *    notice, this list of conditions and the following disclaimer.
  12.  * 2. Redistributions in binary form must reproduce the above copyright
  13.  *    notice, this list of conditions and the following disclaimer in the
  14.  *    documentation and/or other materials provided with the distribution.
  15.  * 3. All advertising materials mentioning features or use of this software
  16.  *    must display the following acknowledgement:
  17.  *    This product includes software developed by the University of
  18.  *    California, Berkeley and its contributors.
  19.  * 4. Neither the name of the University nor the names of its contributors
  20.  *    may be used to endorse or promote products derived from this software
  21.  *    without specific prior written permission.
  22.  *
  23.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  24.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  27.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33.  * SUCH DAMAGE.
  34.  * -
  35.  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
  36.  *
  37.  * Permission to use, copy, modify, and distribute this software for any
  38.  * purpose with or without fee is hereby granted, provided that the above
  39.  * copyright notice and this permission notice appear in all copies, and that
  40.  * the name of Digital Equipment Corporation not be used in advertising or
  41.  * publicity pertaining to distribution of the document or software without
  42.  * specific, written prior permission.
  43.  *
  44.  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
  45.  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
  46.  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
  47.  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  48.  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  49.  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  50.  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  51.  * SOFTWARE.
  52.  * -
  53.  * Portions Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
  54.  * All rights reserved.
  55.  * 
  56.  * Redistribution and use in source and binary forms, with or without
  57.  * modification, are permitted provided that the following conditions
  58.  * are met:
  59.  * 1. Redistributions of source code must retain the above copyright
  60.  *    notice, this list of conditions and the following disclaimer.
  61.  * 2. Redistributions in binary form must reproduce the above copyright
  62.  *    notice, this list of conditions and the following disclaimer in the
  63.  *    documentation and/or other materials provided with the distribution.
  64.  * 3. All advertising materials mentioning features or use of this software
  65.  *    must display the following acknowledgement:
  66.  *    This product includes software developed by WIDE Project and
  67.  *    its contributors.
  68.  * 4. Neither the name of the project nor the names of its contributors
  69.  *    may be used to endorse or promote products derived from this software
  70.  *    without specific prior written permission.
  71.  * 
  72.  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  73.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  74.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  75.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  76.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  77.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  78.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  79.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  80.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  81.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  82.  * SUCH DAMAGE.
  83.  * -
  84.  * --Copyright--
  85.  */
  86.  
  87. /*
  88.  *      @(#)netdb.h    8.1 (Berkeley) 6/2/93
  89.  *    $Id: netdb.h,v 8.15 1999/09/18 06:23:46 vixie Exp $
  90.  */
  91.  
  92. #ifndef _NETDB_H_
  93. #define _NETDB_H_
  94.  
  95. #include <sys/param.h>
  96. #if (!defined(BSD)) || (BSD < 199306)
  97. # include <sys/bitypes.h>
  98. #endif
  99. #include <sys/cdefs.h>
  100. #include <netinet/in.h>
  101. #include <stdio.h>
  102.  
  103. #ifndef _PATH_HEQUIV
  104. #define _PATH_HEQUIV    "/etc/hosts.equiv"
  105. #endif
  106. #ifndef _PATH_HOSTS
  107. #define    _PATH_HOSTS    "/etc/hosts"
  108. #endif
  109. #ifndef _PATH_NETWORKS
  110. #define    _PATH_NETWORKS    "/etc/networks"
  111. #endif
  112. #ifndef _PATH_PROTOCOLS
  113. #define    _PATH_PROTOCOLS    "/etc/protocols"
  114. #endif
  115. #ifndef _PATH_SERVICES
  116. #define    _PATH_SERVICES    "/etc/services"
  117. #endif
  118.  
  119. #ifdef _REENTRANT
  120. __BEGIN_DECLS
  121. extern int * __h_errno __P((void));
  122. __END_DECLS
  123. #define    h_errno (*__h_errno())
  124. #else
  125. extern int h_errno;
  126. #endif
  127.  
  128. /*
  129.  * Structures returned by network data base library.  All addresses are
  130.  * supplied in host order, and returned in network order (suitable for
  131.  * use in system calls).
  132.  */
  133. struct    hostent {
  134.     char    *h_name;    /* official name of host */
  135.     char    **h_aliases;    /* alias list */
  136.     int    h_addrtype;    /* host address type */
  137.     int    h_length;    /* length of address */
  138.     char    **h_addr_list;    /* list of addresses from name server */
  139. #define    h_addr    h_addr_list[0]    /* address, for backward compatiblity */
  140. };
  141.  
  142. /*
  143.  * Assumption here is that a network number
  144.  * fits in an unsigned long -- probably a poor one.
  145.  */
  146. struct    netent {
  147.     char        *n_name;    /* official name of net */
  148.     char        **n_aliases;    /* alias list */
  149.     int        n_addrtype;    /* net address type */
  150.     unsigned long    n_net;        /* network # */
  151. };
  152.  
  153. struct    servent {
  154.     char    *s_name;    /* official service name */
  155.     char    **s_aliases;    /* alias list */
  156.     int    s_port;        /* port # */
  157.     char    *s_proto;    /* protocol to use */
  158. };
  159.  
  160. struct    protoent {
  161.     char    *p_name;    /* official protocol name */
  162.     char    **p_aliases;    /* alias list */
  163.     int    p_proto;    /* protocol # */
  164. };
  165.  
  166. struct    addrinfo {
  167.     int        ai_flags;    /* AI_PASSIVE, AI_CANONNAME */
  168.     int        ai_family;    /* PF_xxx */
  169.     int        ai_socktype;    /* SOCK_xxx */
  170.     int        ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
  171.     size_t        ai_addrlen;    /* length of ai_addr */
  172.     char        *ai_canonname;    /* canonical name for hostname */
  173.     struct sockaddr    *ai_addr;     /* binary address */
  174.     struct addrinfo    *ai_next;     /* next structure in linked list */
  175. };
  176.  
  177. /*
  178.  * Error return codes from gethostbyname() and gethostbyaddr()
  179.  * (left in extern int h_errno).
  180.  */
  181.  
  182. #define    NETDB_INTERNAL    -1    /* see errno */
  183. #define    NETDB_SUCCESS    0    /* no problem */
  184. #define    HOST_NOT_FOUND    1 /* Authoritative Answer Host not found */
  185. #define    TRY_AGAIN    2 /* Non-Authoritive Host not found, or SERVERFAIL */
  186. #define    NO_RECOVERY    3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
  187. #define    NO_DATA        4 /* Valid name, no data record of requested type */
  188. #define    NO_ADDRESS    NO_DATA        /* no address, look for MX record */
  189.  
  190. /*
  191.  * Error return codes from getaddrinfo()
  192.  */
  193.  
  194. #define    EAI_ADDRFAMILY     1    /* address family for hostname not supported */
  195. #define    EAI_AGAIN     2    /* temporary failure in name resolution */
  196. #define    EAI_BADFLAGS     3    /* invalid value for ai_flags */
  197. #define    EAI_FAIL     4    /* non-recoverable failure in name resolution */
  198. #define    EAI_FAMILY     5    /* ai_family not supported */
  199. #define    EAI_MEMORY     6    /* memory allocation failure */
  200. #define    EAI_NODATA     7    /* no address associated with hostname */
  201. #define    EAI_NONAME     8    /* hostname nor servname provided, or not known */
  202. #define    EAI_SERVICE     9    /* servname not supported for ai_socktype */
  203. #define    EAI_SOCKTYPE    10    /* ai_socktype not supported */
  204. #define    EAI_SYSTEM    11    /* system error returned in errno */
  205. #define EAI_BADHINTS    12
  206. #define EAI_PROTOCOL    13
  207. #define EAI_MAX        14
  208.  
  209. /*
  210.  * Flag values for getaddrinfo()
  211.  */
  212. #define    AI_PASSIVE    0x00000001
  213. #define    AI_CANONNAME    0x00000002
  214. #define AI_NUMERICHOST    0x00000004
  215. #define    AI_MASK        0x00000007
  216.  
  217. /*
  218.  * Flag values for getipnodebyname()
  219.  */
  220. #define AI_V4MAPPED    0x00000008
  221. #define AI_ALL        0x00000010
  222. #define AI_ADDRCONFIG    0x00000020
  223. #define AI_DEFAULT    (AI_V4MAPPED|AI_ADDRCONFIG)
  224.  
  225. /*
  226.  * Constants for getnameinfo()
  227.  */
  228. #define    NI_MAXHOST    1025
  229. #define    NI_MAXSERV    32
  230.  
  231. /*
  232.  * Flag values for getnameinfo()
  233.  */
  234. #define    NI_NOFQDN    0x00000001
  235. #define    NI_NUMERICHOST    0x00000002
  236. #define    NI_NAMEREQD    0x00000004
  237. #define    NI_NUMERICSERV    0x00000008
  238. #define    NI_DGRAM    0x00000010
  239.  
  240.  
  241. #ifdef _REENTRANT
  242. #if defined (__hpux) || defined(__osf__)
  243. #define    _MAXALIASES    35
  244. #define    _MAXLINELEN    1024
  245. #define    _MAXADDRS    35
  246. #define    _HOSTBUFSIZE    (BUFSIZ + 1)
  247.  
  248. struct hostent_data {
  249.     struct in_addr    host_addr;
  250.     char        *h_addr_ptrs[_MAXADDRS + 1];
  251.     char        hostaddr[_MAXADDRS];
  252.     char        hostbuf[_HOSTBUFSIZE];
  253.     char        *host_aliases[_MAXALIASES];
  254.     char        *host_addrs[2];
  255.     FILE        *hostf;
  256. #ifdef __osf__
  257.     int        svc_gethostflag;
  258.     int        svc_gethostbind;
  259. #endif
  260. #ifdef __hpux
  261.     short        _nsw_src;
  262.     short        _flags;
  263.     char        *current;
  264.     int        currentlen;
  265. #endif
  266. };
  267.  
  268. struct  netent_data {
  269.     FILE    *net_fp;
  270. #ifdef __osf__
  271.     char    line[_MAXLINELEN];
  272. #endif
  273. #ifdef __hpux
  274.     char    line[_MAXLINELEN+1];
  275. #endif
  276.     char    *net_aliases[_MAXALIASES];
  277. #ifdef __osf__
  278.     int    _net_stayopen;
  279.     int    svc_getnetflag;
  280. #endif
  281. #ifdef __hpux
  282.     short    _nsw_src;
  283.     short    _flags;
  284.     char    *current;
  285.     int    currentlen;
  286. #endif
  287. };
  288.  
  289. struct    protoent_data {
  290.     FILE    *proto_fp;
  291. #ifdef __osf__
  292.     char    line[1024];
  293. #endif
  294. #ifdef __hpux
  295.     char    line[_MAXLINELEN+1];
  296. #endif
  297.     char    *proto_aliases[_MAXALIASES];
  298. #ifdef __osf__
  299.     int    _proto_stayopen;
  300.     int    svc_getprotoflag;
  301. #endif
  302. #ifdef __hpux
  303.     short    _nsw_src;
  304.     short    _flags;
  305.     char    *current;
  306.     int    currentlen;
  307. #endif
  308. };
  309.  
  310. struct    servent_data {
  311.     FILE    *serv_fp;
  312. #ifdef __osf__
  313.     char    line[_MAXLINELEN];
  314. #endif
  315. #ifdef __hpux
  316.     char    line[_MAXLINELEN+1];
  317. #endif
  318.     char    *serv_aliases[_MAXALIASES];
  319. #ifdef __osf__
  320.     int    _serv_stayopen;
  321.     int    svc_getservflag;
  322. #endif
  323. #ifdef __hpux
  324.     short    _nsw_src;
  325.     short    _flags;
  326.     char    *current;
  327.     int    currentlen;
  328. #endif
  329. };
  330. #endif
  331. #endif
  332. __BEGIN_DECLS
  333. void        endhostent __P((void));
  334. void        endnetent __P((void));
  335. void        endprotoent __P((void));
  336. void        endservent __P((void));
  337. struct hostent    *gethostbyaddr __P((const char *, int, int));
  338. struct hostent    *gethostbyname __P((const char *));
  339. struct hostent    *gethostbyname2 __P((const char *, int));
  340. struct hostent    *gethostent __P((void));
  341. struct netent    *getnetbyaddr __P((unsigned long, int));
  342. struct netent    *getnetbyname __P((const char *));
  343. struct netent    *getnetent __P((void));
  344. struct protoent    *getprotobyname __P((const char *));
  345. struct protoent    *getprotobynumber __P((int));
  346. struct protoent    *getprotoent __P((void));
  347. struct servent    *getservbyname __P((const char *, const char *));
  348. struct servent    *getservbyport __P((int, const char *));
  349. struct servent    *getservent __P((void));
  350. void        herror __P((const char *));
  351. const char    *hstrerror __P((int));
  352. void        sethostent __P((int));
  353. /* void        sethostfile __P((const char *)); */
  354. void        setnetent __P((int));
  355. void        setprotoent __P((int));
  356. void        setservent __P((int));
  357. int        getaddrinfo __P((const char *, const char *,
  358.                  const struct addrinfo *, struct addrinfo **));
  359. int        getnameinfo __P((const struct sockaddr *, size_t, char *,
  360.                  size_t, char *, size_t, int));
  361. void        freeaddrinfo __P((struct addrinfo *));
  362. char        *gai_strerror __P((int));
  363. struct hostent  *getipnodebyname __P((const char *, int, int, int *));
  364. struct hostent    *getipnodebyaddr __P((const void *, size_t, int, int *));
  365. void        freehostent __P((struct hostent *));
  366.  
  367.  
  368. #ifdef _REENTRANT
  369. #if defined(__hpux) || defined(__osf__)
  370. int        gethostbyaddr_r __P((const char *, int, int, struct hostent *,
  371.                     struct hostent_data *));
  372. int        gethostbyname_r __P((const char *, struct hostent *, 
  373.                     struct hostent_data *));
  374. int        gethostent_r __P((struct hostent *, struct hostent_data *));
  375. int        sethostent_r __P((int, struct hostent_data *));
  376. #if defined(__hpux)
  377. int        endhostent_r __P((struct hostent_data *));
  378. #else
  379. void        endhostent_r __P((struct hostent_data *));
  380. #endif
  381.  
  382. #ifdef __hpux
  383. int        getnetbyaddr_r __P((int, int,
  384.                 struct netent *, struct netent_data *));
  385. #else
  386. int        getnetbyaddr_r __P((long, int,
  387.                 struct netent *, struct netent_data *));
  388. #endif
  389. int        getnetbyname_r __P((const char *,
  390.                 struct netent *, struct netent_data *));
  391. int        getnetent_r __P((struct netent *, struct netent_data *));
  392. int        setnetent_r __P((int, struct netent_data *));
  393. #ifdef __hpux
  394. int        endnetent_r __P((struct netent_data *buffer));
  395. #else
  396. void        endnetent_r __P((struct netent_data *buffer));
  397. #endif
  398.  
  399. int        getprotobyname_r __P((const char *,
  400.                 struct protoent *, struct protoent_data *));
  401. int        getprotobynumber_r __P((int,
  402.                 struct protoent *, struct protoent_data *));
  403. int        getprotoent_r __P((struct protoent *, struct protoent_data *));
  404. int        setprotoent_r __P((int, struct protoent_data *));
  405. #ifdef __hpux
  406. int        endprotoent_r __P((struct protoent_data *));
  407. #else
  408. void        endprotoent_r __P((struct protoent_data *));
  409. #endif
  410.  
  411. int        getservbyname_r __P((const char *, const char *,
  412.                 struct servent *, struct servent_data *));
  413. int        getservbyport_r __P((int, const char *,
  414.                 struct servent *, struct servent_data *));
  415. int        getservent_r __P((struct servent *, struct servent_data *));
  416. int        setservent_r __P((int, struct servent_data *));
  417. #ifdef __hpux
  418. int        endservent_r __P((struct servent_data *));
  419. #else
  420. void        endservent_r __P((struct servent_data *));
  421. #endif
  422. #endif
  423. #if defined(sun) || defined(bsdi)
  424. struct hostent    *gethostbyaddr_r __P((const char *, int, int, struct hostent *,
  425.                     char *, int, int *));
  426. struct hostent    *gethostbyname_r __P((const char *, struct hostent *,
  427.                     char *, int, int *));
  428. struct hostent    *gethostent_r __P((struct hostent *, char *, int, int *));
  429. void        sethostent_r __P((int));
  430. void        endhostent_r __P((void));
  431.  
  432. struct netent    *getnetbyname_r __P((const char *, struct netent *,
  433.                     char *, int));
  434. struct netent    *getnetbyaddr_r __P((long, int, struct netent *,
  435.                     char *, int));
  436. struct netent    *getnetent_r __P((struct netent *, char *, int));
  437. void        setnetent_r __P((int));
  438. void        endnetent_r __P((void));
  439.  
  440. struct protoent    *getprotobyname_r __P((const char *,
  441.                 struct protoent *, char *, int));
  442. struct protoent    *getprotobynumber_r __P((int,
  443.                 struct protoent *, char *, int));
  444. struct protoent    *getprotoent_r __P((struct protoent *, char *, int));
  445. void        setprotoent_r __P((int));
  446. void        endprotoent_r __P((void));
  447.  
  448. struct servent    *getservbyname_r __P((const char *name, const char *,
  449.                     struct servent *, char *, int));
  450. struct servent    *getservbyport_r __P((int port, const char *,
  451.                     struct servent *, char *, int));
  452. struct servent    *getservent_r __P((struct servent *, char *, int));
  453. void        setservent_r __P((int));
  454. void        endservent_r __P((void));
  455.  
  456. #endif
  457. #endif
  458. __END_DECLS
  459.  
  460. /* This is nec'y to make this include file properly replace the sun version. */
  461. #ifdef sun
  462. #ifdef __GNU_LIBRARY__
  463. #include <rpc/netdb.h>
  464. #else
  465. struct rpcent {
  466.     char    *r_name;    /* name of server for this rpc program */
  467.     char    **r_aliases;    /* alias list */
  468.     int    r_number;    /* rpc program number */
  469. };
  470. struct rpcent    *getrpcbyname(), *getrpcbynumber(), *getrpcent();
  471. #endif /* __GNU_LIBRARY__ */
  472. #endif /* sun */
  473.  
  474. #endif /* !_NETDB_H_ */
  475.